import { constantRoutes, asyncRoutes } from '@/router'

const state = {
  routes: []
}
const mutations = {
  setRoutes(state, payload) {
    state.routes = [...constantRoutes, ...payload]
  }
}
const actions = {
  filterRoutes({ commit }, menus) {
    const permmison = asyncRoutes.filter(item => {
      return menus.some(menu => {
        return menu === item.name
      })
    })
    // console.log(permmison)
    commit('setRoutes', permmison)
    return permmison
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
